﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Threading.Tasks;
using YiSha.Util;
using YiSha.Util.Extension;
using YiSha.Util.Model;
using YiSha.Entity.YiDongYuan;
using YiSha.Model.Param.YiDongYuan;
using YiSha.Service.YiDongYuan;
using YiSha.Web.Code;

namespace YiSha.Business.YiDongYuan
{
    /// <summary>
    /// 创 建：admin
    /// 日 期：2021-06-09 12:00
    /// 描 述：检测详细信息业务类
    /// </summary>
    public class DetectionInfoBLL
    {
        private DetectionInfoService detectionInfoService = new DetectionInfoService();

        #region 获取数据

        public async Task<TData<List<DetectionInfoEntity>>> GetList(DetectionInfoListParam param)
        {
            TData<List<DetectionInfoEntity>> obj = new TData<List<DetectionInfoEntity>>();
            obj.Data = await detectionInfoService.GetList(param);
            obj.Total = obj.Data.Count;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<List<DetectionInfoEntity>>> GetPageList(DetectionInfoListParam param, Pagination pagination)
        {
            TData<List<DetectionInfoEntity>> obj = new TData<List<DetectionInfoEntity>>();
            obj.Data = await detectionInfoService.GetPageList(param, pagination);
            obj.Total = pagination.TotalCount;
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData<DetectionInfoEntity>> GetEntity(long id)
        {
            TData<DetectionInfoEntity> obj = new TData<DetectionInfoEntity>();
            obj.Data = await detectionInfoService.GetEntity(id);
            if (obj.Data != null)
            {
                obj.Tag = 1;
            }
            return obj;
        }

        #endregion 获取数据

        #region 提交数据

        public async Task<TData<string>> SaveForm(DetectionInfoEntity entity, OperatorInfo user)
        {
            TData<string> obj = new TData<string>();
            await detectionInfoService.SaveForm(entity, user);
            obj.Data = entity.Id.ParseToString();
            obj.Tag = 1;
            return obj;
        }

        public async Task<TData> DeleteForm(string ids)
        {
            TData obj = new TData();
            await detectionInfoService.DeleteForm(ids);
            obj.Tag = 1;
            return obj;
        }

        #endregion 提交数据
    }
}
